<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML>
<html>
  <head> 
	<%@ include file="/platform/style.jsp"%>
	<script type="text/javascript" src="${ctx}/plugins/plupload2/plupload.full.min.js"></script>
	<script type="text/javascript" src="${ctx}/plugins/oss/upload.js"></script>
	<style>
		#codeimg img{width:100px;height:100px;}
		.pl_upimgdiv{position: relative;}
		.pl_upimgdiv .progresstxt{display:none;width:100%;height:12px;line-height:12px;text-align:center;font-size:10px;color:red;position: absolute;bottom:0px;}
		.pl_upimgdiv .progressbg{width:0;position:absolute;background:#00CD26;bottom:0px;height:12px;font-size:0px;}
		.pl_upimgdiv .file_del{position:absolute;top:2px;right:2px;display:block;width:15px;height:15px;background:url(${ctx}/plugins/plupload2/filedel.jpg);}
  	
	</style>
	
  </head>
  
  <body class="easyui-layout">
  	<div data-options="region:'north'" style="height:38px">
		<div class="ui-buttonBar" style="text-align:center">
			<a href="javascript:;" class="easyui-linkbutton"  onclick="tosave()">保 存</a>
		</div>
	</div>
	<div data-options="region:'center'" class="ui-formContent" style="background:#fff">
		<div class="line8"></div><div class="line8"></div>
		<form action="/sysman/SysmanPage@saveSyspro.page" method="post">
		<table>
		<!-- 
		<tr>
			<td width="280" align="right">互联网药品交易服务资格证书：</td><td><w:text bind="bean.hlwjyzg" style="width:400px"/></td>
		</tr>
		 -->
		<tr><td><div class="line8"></div></td></tr>
		<tr>
			<td width="280" align="right">药品经营许可证：</td><td><w:text bind="bean.ypjyxk" style="width:400px"/></td>
		</tr>
		<tr><td><div class="line8"></div></td></tr>
		<tr>
			<td align="right">全国服务热线：</td><td><w:text bind="bean.fuwu_phone" style="width:400px"/></td>
		</tr>
		<tr><td><div class="line8"></div></td></tr>
		<tr>
			<td align="right">服务时间：</td><td><w:text bind="bean.fuwu_time" style="width:400px"/></td>
		</tr>
		<tr><td><div class="line8"></div></td></tr>
		<tr>
			<td align="right">电子邮箱：</td><td><w:text bind="bean.fuwu_email" style="width:400px"/></td>
		</tr>
		<tr><td><div class="line8"></div></td></tr>
		<tr>
			<td align="right">查询药品备案信息地址：</td><td><w:text bind="bean.cxbadiz" style="width:400px"/></td>
		</tr>
		<tr><td><div class="line8"></div></td></tr>
		<tr>
			<td align="right">二维码图片：</td><td>
				<w:hidden bind="bean.webqrcode"/>
				<div id="codeimg" style="width:100px;height:100px;"><img src="${fileserver }<w:write bind="bean.webqrcode"/>" onerror="this.src='<%=path%>/images/addimg.jpg'"></div>
				<div><a href="javascript:;" id="upimgbtn" class="ui_btn" style="width:80px">选择图片</a></div>
			</td>
		</tr>
		<tr><td><div class="line8"></div></td></tr>
		<tr>
			<td align="right">订单自动确认：</td><td><w:radio bind="bean.orderswitch" value="0" text="开启"/><w:radio bind="bean.orderswitch" value="1" text="关闭"/></td>
		</tr>
		<tr><td><div class="line8"></div></td></tr>
		</table>
		</form>
	</div>
  </body>
</html>
<script>
	var uploader;
	$(function(){
		var plparm={
			runtimes : 'html5,flash,silverlight,html4',
			browse_button :'upimgbtn',
			url : '',
			flash_swf_url : ctx+'/plugins/plupload2/Moxie2.swf',
			silverlight_xap_url : ctx+'/plugins/plupload2/Moxie.xap',
			multi_selection:false,
			filters: {
				max_file_size : '500kb',
				prevent_duplicates :false, //不允许选取重复文件
			  	mime_types : [ //只允许上传图片文件
			    { title : "图片文件", extensions : "jpg,png" }
			  	]
			},init:{
				FilesAdded: function(up, files) {
					for(var i=0;i<up.files.length-1;i++){
						up.removeFile(up.files[0]);
					}
					previewImageOne(files[0],function(imgsrc){
						$("#codeimg").html("<div class='pl_upimgdiv'><img src='"+imgsrc+"'><div class='progressbg'></div><div class='progresstxt'>请保持上传</div></div>")
					})
				},UploadFile:function(up,file){
					var f=$('#img_'+file.id);
					$(".progresstxt",f).show();
				},UploadProgress:function(up,file){
					var f=$('.pl_upimgdiv');
					var d=$(".progressbg",f);
					var w=f.width()*parseInt(file.percent)/100;
					d.css("width",w+"px");
					$(".progresstxt",f).html(file.percent+"%");
				},FileUploaded:function(up,file,responseObject){
					var re=jQuery.parseJSON(responseObject.response);
					$("[name='bean.webqrcode']").val(re.url.replace(re.basepath,""));
				},UploadComplete:function(){
					submitdata();
				},Error:function(up, err){
					if(err.code!="-602"){
						if(err.code=="-600")
							alert("图片大小不能超过500kb");
						else
							alert(err.code+"-"+err.message);
					}
					return false;
				}
			}
		};
		$oss.setUpDir('pictures');
		uploader=$oss.initUpload(plparm);
	})
	
	function previewImageOne(file,callback){
		if(!file || !/image\//.test(file.type)) return;
		if(file.type=='image/gif'){
			var fr2 = new mOxie.FileReader();
			fr2.onload = function(){
				callback(fr2.result);
				fr2.destroy();
				fr2 = null;
			}
			fr2.readAsDataURL(file.getSource());
		}else{
			var preloader = new mOxie.Image();
			preloader.onload = function() {
				//preloader.downsize( 300, 300 );
				var imgsrc = preloader.type=='image/jpeg' ? preloader.getAsDataURL('image/jpeg',80) : preloader.getAsDataURL(); //得到图片src,实质为一个base64编码的数据
				callback && callback(imgsrc);
				preloader.destroy();
				preloader = null;
			};
			preloader.load( file.getSource() );
		}
	}
	function tosave(){
		if(uploader.files.length>0)
			uploader.start();
		else submitdata();
	}
	function submitdata(){
		$w.doForm({callback:function(ret){
			if(ret.state=='ok'){
				window.parent.$w.correctMsg("保存成功！");
			}
		}});
	}
</script>